﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;

namespace OpenApi
{
	/// <summary>
	/// 认证操作行为
	/// </summary>
	public class AuthOperationBehavior : IOperationBehavior
	{
		private IAuthProvider m_Auth;

		public AuthOperationBehavior(IAuthProvider auth)
		{
			this.m_Auth = auth;
		}

		public void AddBindingParameters(OperationDescription operationDescription, System.ServiceModel.Channels.BindingParameterCollection bindingParameters)
		{
			return;
		}

		public void ApplyClientBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.ClientOperation clientOperation)
		{
			return;
		}

		public void ApplyDispatchBehavior(OperationDescription operationDescription, System.ServiceModel.Dispatcher.DispatchOperation dispatchOperation)
		{
			dispatchOperation.Invoker = new AuthOperationInvoker(operationDescription, dispatchOperation.Invoker, m_Auth);
		}

		public void Validate(OperationDescription operationDescription)
		{
			return;
		}
	}
}
